<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.8.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"forkdog.github.io","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="ls 常用选项ls 是英文单词 list 的简写，其功能为列出目录的内容，是用户最常用的命令之一    参数 含义     -a 显示指定目录下所有子目录与文件，包括隐藏文件   -l 以列表方式显示文件的详细信息   -h 配合 -l 以人性化的方式显示文件大小    ls 通配符的使用   * 代表任意个数个字符     ? 代表任意一个字符，至少 1 个   [] 表示可以匹配字符组中的任一">
<meta name="keywords" content="Linux">
<meta property="og:type" content="article">
<meta property="og:title" content="常用 Linux 命令的基本使用">
<meta property="og:url" content="https://forkdog.github.io/2018/12/17/常用Linux命令的基本使用/index.html">
<meta property="og:site_name" content="forkdog">
<meta property="og:description" content="ls 常用选项ls 是英文单词 list 的简写，其功能为列出目录的内容，是用户最常用的命令之一    参数 含义     -a 显示指定目录下所有子目录与文件，包括隐藏文件   -l 以列表方式显示文件的详细信息   -h 配合 -l 以人性化的方式显示文件大小    ls 通配符的使用   * 代表任意个数个字符     ? 代表任意一个字符，至少 1 个   [] 表示可以匹配字符组中的任一">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-12-20T02:34:13.832Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="常用 Linux 命令的基本使用">
<meta name="twitter:description" content="ls 常用选项ls 是英文单词 list 的简写，其功能为列出目录的内容，是用户最常用的命令之一    参数 含义     -a 显示指定目录下所有子目录与文件，包括隐藏文件   -l 以列表方式显示文件的详细信息   -h 配合 -l 以人性化的方式显示文件大小    ls 通配符的使用   * 代表任意个数个字符     ? 代表任意一个字符，至少 1 个   [] 表示可以匹配字符组中的任一">

<link rel="canonical" href="https://forkdog.github.io/2018/12/17/常用Linux命令的基本使用/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-Hans'
  };
</script>

  <title>常用 Linux 命令的基本使用 | forkdog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">forkdog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">记录学习的地方</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">7</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" placeholder="搜索..." spellcheck="false" type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope="" itemtype="http://schema.org/Article" class="post-block" lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="https://forkdog.github.io/2018/12/17/常用Linux命令的基本使用/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="forkdog">
      <meta itemprop="description" content="幸福需要自己感知，决定需要自己来做。">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="forkdog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          常用 Linux 命令的基本使用
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2018-12-17 17:33:29" itemprop="dateCreated datePublished" datetime="2018-12-17T17:33:29+08:00">2018-12-17</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2018-12-20 10:34:13" itemprop="dateModified" datetime="2018-12-20T10:34:13+08:00">2018-12-20</time>
              </span>

          
            <span id="/2018/12/17/常用Linux命令的基本使用/" class="post-meta-item leancloud_visitors" data-flag-title="常用 Linux 命令的基本使用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="ls-常用选项"><a href="#ls-常用选项" class="headerlink" title="ls 常用选项"></a>ls 常用选项</h3><p><code>ls</code> 是英文单词 <strong>list</strong> 的简写，其功能为列出目录的内容，是用户最常用的命令之一</p>
<table>
<thead>
<tr>
<th style="text-align:left">参数</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">-a</td>
<td>显示指定目录下所有子目录与文件，包括隐藏文件</td>
</tr>
<tr>
<td style="text-align:left">-l</td>
<td>以列表方式显示文件的详细信息</td>
</tr>
<tr>
<td style="text-align:left">-h</td>
<td>配合 -l 以人性化的方式显示文件大小</td>
</tr>
</tbody>
</table>
<h4 id="ls-通配符的使用"><a href="#ls-通配符的使用" class="headerlink" title="ls 通配符的使用"></a>ls 通配符的使用</h4><table>
<thead>
<tr>
<th style="text-align:left">*</th>
<th>代表任意个数个字符</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">?</td>
<td>代表任意一个字符，至少 1 个</td>
</tr>
<tr>
<td style="text-align:left">[]</td>
<td>表示可以匹配字符组中的任一一个</td>
</tr>
<tr>
<td style="text-align:left">[abc]</td>
<td>匹配 a、b、c 中的任意一个</td>
</tr>
<tr>
<td style="text-align:left">[a-f]</td>
<td>匹配从 a 到 f 范围内的的任意一个字符</td>
</tr>
</tbody>
</table>
<h3 id="cd"><a href="#cd" class="headerlink" title="cd"></a>cd</h3><p><code>cd</code> 是英文单词 <strong>change directory</strong> 的简写，其功能为更改当前的工作目录，也是用户最常用的命令之一</p>
<blockquote>
<p>注意：Linux 所有的 <strong>目录</strong> 和 <strong>文件名</strong> 都是大小写敏感的</p>
</blockquote>
<table>
<thead>
<tr>
<th>cd ~</th>
<th>切换到当前用户的主目录(/home/用户目录)</th>
</tr>
</thead>
<tbody>
<tr>
<td>cd .</td>
<td>保持在当前目录不变</td>
</tr>
<tr>
<td>cd ..</td>
<td>切换到上级目录</td>
</tr>
<tr>
<td>cd -</td>
<td>可以在最近两次工作目录之间来回切换</td>
</tr>
</tbody>
</table>
<h4 id="相对路径和绝对路径"><a href="#相对路径和绝对路径" class="headerlink" title="相对路径和绝对路径"></a>相对路径和绝对路径</h4><ul>
<li><strong>相对路径</strong> 在输入路径时，最前面不是 <strong>/</strong> 或者 <strong>~</strong>，表示相对 <strong>当前目录</strong> 所在的目录位置</li>
<li><strong>绝对路径</strong> 在输入路径时，最前面是 <strong>/</strong> 或者 <strong>~</strong>，表示从 <strong>根目录/家目录</strong> 开始的具体目录位置</li>
</ul>
<h3 id="创建和删除操作"><a href="#创建和删除操作" class="headerlink" title="创建和删除操作"></a>创建和删除操作</h3><h4 id="touch"><a href="#touch" class="headerlink" title="touch"></a>touch</h4><p>创建文件或修改文件时间</p>
<ul>
<li>如果文件 <strong>不存在</strong>，可以创建一个空白文件</li>
<li>如果文件 <strong>已经存在</strong>，可以修改文件的末次修改日期</li>
</ul>
<h4 id="mkdir"><a href="#mkdir" class="headerlink" title="mkdir"></a>mkdir</h4><ul>
<li>创建一个新的目录</li>
</ul>
<table>
<thead>
<tr>
<th>选项</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>-p</td>
<td style="text-align:left">可以递归创建目录</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>新建目录的名称</strong> 不能与当前目录中 <strong>已有的目录或文件</strong> 同名</p>
</blockquote>
<h4 id="rm"><a href="#rm" class="headerlink" title="rm"></a>rm</h4><ul>
<li>删除文件或目录</li>
</ul>
<blockquote>
<p>使用 <code>rm</code> 命令要小心，因为文件删除后不能恢复</p>
</blockquote>
<table>
<thead>
<tr>
<th>选项</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>-f</td>
<td style="text-align:left">强制删除，忽略不存在的文件，无需提示</td>
</tr>
<tr>
<td>-r</td>
<td style="text-align:left">递归地删除目录下的内容，<strong>删除文件夹</strong> 时必须加此参数</td>
</tr>
</tbody>
</table>
<h3 id="拷贝和移动文件"><a href="#拷贝和移动文件" class="headerlink" title="拷贝和移动文件"></a>拷贝和移动文件</h3><table>
<thead>
<tr>
<th>序号</th>
<th>命令</th>
<th>对应英文</th>
<th>作用</th>
</tr>
</thead>
<tbody>
<tr>
<td>01</td>
<td>tree [目录名]</td>
<td>tree</td>
<td>以树状图列出文件目录结构</td>
</tr>
<tr>
<td>02</td>
<td>cp 源文件 目标文件</td>
<td>copy</td>
<td>复制文件或者目录</td>
</tr>
<tr>
<td>03</td>
<td>mv 源文件 目标文件</td>
<td>move</td>
<td>移动文件或者目录／文件或者目录重命名</td>
</tr>
</tbody>
</table>
<h3 id="tree"><a href="#tree" class="headerlink" title="tree"></a>tree</h3><ul>
<li><code>tree</code> 命令可以以树状图列出文件目录结构</li>
</ul>
<table>
<thead>
<tr>
<th>选项</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>-d</td>
<td>只显示目录</td>
</tr>
</tbody>
</table>
<h4 id="cp"><a href="#cp" class="headerlink" title="cp"></a>cp</h4><ul>
<li><code>cp</code> 命令的功能是将给出的 <strong>文件</strong> 或 <strong>目录</strong> 复制到另一个 <strong>文件</strong> 或 <strong>目录</strong> 中，相当于 <strong>DOS</strong> 下的 <code>copy</code> 命令</li>
</ul>
<table>
<thead>
<tr>
<th>选项</th>
<th style="text-align:left">含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>-i</td>
<td style="text-align:left">覆盖文件前提示</td>
</tr>
<tr>
<td>-r</td>
<td style="text-align:left">若给出的源文件是目录文件，则 cp 将递归复制该目录下的所有子目录和文件，目标文件必须为一个目录名</td>
</tr>
</tbody>
</table>
<h4 id="mv"><a href="#mv" class="headerlink" title="mv"></a>mv</h4><ul>
<li><code>mv</code> 命令可以用来 <strong>移动</strong> <strong>文件</strong> 或 <strong>目录</strong>，也可以给 <strong>文件或目录重命名</strong></li>
</ul>
<table>
<thead>
<tr>
<th style="text-align:left">选项</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">-i</td>
<td>覆盖文件前提示</td>
</tr>
</tbody>
</table>
<h3 id="查看文件内容"><a href="#查看文件内容" class="headerlink" title="查看文件内容"></a>查看文件内容</h3><table>
<thead>
<tr>
<th>序号</th>
<th>命令</th>
<th>对应英文</th>
<th style="text-align:left">作用</th>
</tr>
</thead>
<tbody>
<tr>
<td>01</td>
<td>cat 文件名</td>
<td>concatenate</td>
<td style="text-align:left">查看文件内容、创建文件、文件合并、追加文件内容等功能</td>
</tr>
<tr>
<td>02</td>
<td>more 文件名</td>
<td>more</td>
<td style="text-align:left">分屏显示文件内容</td>
</tr>
<tr>
<td>03</td>
<td>grep 搜索文本 文件名</td>
<td>grep</td>
<td style="text-align:left">搜索文本文件内容</td>
</tr>
</tbody>
</table>
<h4 id="cat"><a href="#cat" class="headerlink" title="cat"></a>cat</h4><ul>
<li><code>cat</code> 命令可以用来 <strong>查看文件内容</strong>、<strong>创建文件</strong>、<strong>文件合并</strong>、<strong>追加文件内容</strong> 等功能</li>
<li><code>cat</code> 会一次显示所有的内容，适合 <strong>查看内容较少</strong> 的文本文件</li>
</ul>
<table>
<thead>
<tr>
<th>选项</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>-b</td>
<td>对非空输出行编号</td>
</tr>
<tr>
<td>-n</td>
<td>对输出的所有行编号</td>
</tr>
</tbody>
</table>
<blockquote>
<p>Linux 中还有一个 <code>nl</code> 的命令和 <code>cat -b</code> 的效果等价</p>
</blockquote>
<h4 id="more"><a href="#more" class="headerlink" title="more"></a>more</h4><ul>
<li><code>more</code> 命令可以用于分屏显示文件内容，每次只显示一页内容</li>
<li>适合于 <strong>查看内容较多</strong>的文本文件</li>
</ul>
<p>使用 <code>more</code> 的操作键：</p>
<table>
<thead>
<tr>
<th>操作键</th>
<th style="text-align:left">功能</th>
</tr>
</thead>
<tbody>
<tr>
<td>空格键</td>
<td style="text-align:left">显示手册页的下一屏</td>
</tr>
<tr>
<td>Enter 键</td>
<td style="text-align:left">一次滚动手册页的一行</td>
</tr>
<tr>
<td>b</td>
<td style="text-align:left">回滚一屏</td>
</tr>
<tr>
<td>f</td>
<td style="text-align:left">前滚一屏</td>
</tr>
<tr>
<td>q</td>
<td style="text-align:left">退出</td>
</tr>
<tr>
<td>/word</td>
<td style="text-align:left">搜索 <strong>word</strong> 字符串</td>
</tr>
</tbody>
</table>
<h4 id="grep"><a href="#grep" class="headerlink" title="grep"></a>grep</h4><ul>
<li>Linux 系统中 <code>grep</code> 命令是一种强大的文本搜索工具</li>
<li><code>grep</code>允许对文本文件进行 <strong>模式</strong>查找，所谓模式查找，又被称为正则表达式，在就业班会详细讲解</li>
</ul>
<table>
<thead>
<tr>
<th>选项</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>-n</td>
<td>显示匹配行及行号</td>
</tr>
<tr>
<td>-v</td>
<td>显示不包含匹配文本的所有行（相当于求反）</td>
</tr>
<tr>
<td>-i</td>
<td>忽略大小写</td>
</tr>
</tbody>
</table>
<ul>
<li>常用的两种模式查找</li>
</ul>
<table>
<thead>
<tr>
<th>参数</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>^a</td>
<td>行首，搜寻以 <strong>a</strong> 开头的行</td>
</tr>
<tr>
<td>a$</td>
<td>行尾，搜寻以 <strong>a</strong> 结束的行</td>
</tr>
</tbody>
</table>
<h3 id="echo"><a href="#echo" class="headerlink" title="echo"></a>echo</h3><ul>
<li><code>echo</code> 会在终端中显示参数指定的文字，通常会和 <strong>重定向</strong> 联合使用</li>
<li>重定向 <code>&gt;</code> 和 <code>&gt;&gt;</code><ul>
<li>Linux 允许将命令执行结果 <strong>重定向</strong>到一个 <strong>文件</strong></li>
<li>将本应显示在<strong>终端上的内容</strong> <strong>输出／追加</strong> 到<strong>指定文件中</strong></li>
<li><code>&gt;</code> 表示输出，会覆盖文件原有的内容</li>
<li><code>&gt;&gt;</code> 表示追加，会将内容追加到已有文件的末尾</li>
</ul>
</li>
</ul>
<h3 id="管道"><a href="#管道" class="headerlink" title="管道 |"></a>管道 <code>|</code></h3><ul>
<li>Linux 允许将 <strong>一个命令的输出</strong> 可以<strong>通过管道</strong> 做为 <strong>另一个命令的输入</strong></li>
<li>可以理解现实生活中的管子，管子的一头塞东西进去，另一头取出来，这里 <code>|</code> 的左右分为两端，左端塞东西（写），右端取东西（读）</li>
</ul>
<p>常用的管道命令有：</p>
<ul>
<li><code>more</code>：分屏显示内容</li>
<li><code>grep</code>：在命令执行结果的基础上查询指定的文本</li>
</ul>
<h3 id="exec"><a href="#exec" class="headerlink" title="exec"></a>exec</h3><p><code>-exec</code>  参数后面跟的是 command 命令，它的终止是以“；”为结束标志的，所以这句命令后面的分号是不可缺少的，考虑到各个系统中分号会有不同的意义，所以前面加反斜杠。</p>
<p>例如：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find . -name *.png -<span class="built_in">exec</span> mv &#123;&#125; 移动目录/ \;</span><br></pre></td></tr></table></figure>

    </div>

    
    
    
        <div class="reward-container">
  <div></div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.jpg" alt="forkdog 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/images/alipay.jpg" alt="forkdog 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>forkdog
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://forkdog.github.io/2018/12/17/常用Linux命令的基本使用/" title="常用 Linux 命令的基本使用">https://forkdog.github.io/2018/12/17/常用Linux命令的基本使用/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Linux/" rel="tag"># Linux</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2018/12/17/Linux文件和目录/" rel="prev" title="Linux文件和目录">
      <i class="fa fa-chevron-left"></i> Linux文件和目录
    </a></div>
      <div class="post-nav-item">
    <a href="/2018/12/20/Linux-远程管理常用命令/" rel="next" title="Linux 远程管理常用命令">
      Linux 远程管理常用命令 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#ls-常用选项"><span class="nav-number">1.</span> <span class="nav-text">ls 常用选项</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#ls-通配符的使用"><span class="nav-number">1.1.</span> <span class="nav-text">ls 通配符的使用</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#cd"><span class="nav-number">2.</span> <span class="nav-text">cd</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#相对路径和绝对路径"><span class="nav-number">2.1.</span> <span class="nav-text">相对路径和绝对路径</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#创建和删除操作"><span class="nav-number">3.</span> <span class="nav-text">创建和删除操作</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#touch"><span class="nav-number">3.1.</span> <span class="nav-text">touch</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#mkdir"><span class="nav-number">3.2.</span> <span class="nav-text">mkdir</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#rm"><span class="nav-number">3.3.</span> <span class="nav-text">rm</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#拷贝和移动文件"><span class="nav-number">4.</span> <span class="nav-text">拷贝和移动文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#tree"><span class="nav-number">5.</span> <span class="nav-text">tree</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#cp"><span class="nav-number">5.1.</span> <span class="nav-text">cp</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#mv"><span class="nav-number">5.2.</span> <span class="nav-text">mv</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#查看文件内容"><span class="nav-number">6.</span> <span class="nav-text">查看文件内容</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#cat"><span class="nav-number">6.1.</span> <span class="nav-text">cat</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#more"><span class="nav-number">6.2.</span> <span class="nav-text">more</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#grep"><span class="nav-number">6.3.</span> <span class="nav-text">grep</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#echo"><span class="nav-number">7.</span> <span class="nav-text">echo</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#管道"><span class="nav-number">8.</span> <span class="nav-text">管道 |</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#exec"><span class="nav-number">9.</span> <span class="nav-text">exec</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">forkdog</p>
  <div class="site-description" itemprop="description">幸福需要自己感知，决定需要自己来做。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">7</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/forkDog" title="GitHub → https://github.com/forkDog" rel="noopener" target="_blank"><i class="github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:2663986085@qq.com" title="E-Mail → mailto:2663986085@qq.com" rel="noopener" target="_blank"><i class="envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">forkdog</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>






<script>
  (function() {
    function leancloudSelector(url) {
      url = encodeURI(url);
      return document.getElementById(url).querySelector('.leancloud-visitors-count');
    }

    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = decodeURI(visitors.id);
      var title = visitors.dataset.flagTitle;

      Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({ url })))
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
            leancloudSelector(url).innerText = counter.time + 1;
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .catch(error => {
                console.error('Failed to save visitor count', error);
              });
          } else {
              leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';
              console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
            
          }
        })
        .catch(error => {
          console.error('LeanCloud Counter Error', error);
        });
    }

    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return decodeURI(element.id);
      });

      Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({ url: { '$in': entries } })))
        .then(response => response.json())
        .then(({ results }) => {
          for (let url of entries) {
            let target = results.find(item => item.url === url);
            leancloudSelector(url).innerText = target ? target.time : 0;
          }
        })
        .catch(error => {
          console.error('LeanCloud Counter Error', error);
        });
    }

    let { app_id, app_key, server_url } = {"enable":true,"app_id":"Fm93tUtkusYaPE2NSNYpPmdm-gzGzoHsz","app_key":"QmMnMp5rsYr3cBcSRe7SsKwm","server_url":null,"security":true};
    function fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${api_server}/1.1${url}`, {
          method,
          headers: {
            'X-LC-Id'     : app_id,
            'X-LC-Key'    : app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        if (CONFIG.hostname !== location.hostname) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    }

    let api_server = app_id.slice(-9) !== '-MdYXbMMI' ? server_url : `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com`;

    if (api_server) {
      fetchData(api_server);
    } else {
      fetch('https://app-router.leancloud.cn/2/route?appId=' + app_id)
        .then(response => response.json())
        .then(({ api_server }) => {
          fetchData('https://' + api_server);
        });
    }
  })();
</script>


      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>



  




  <script src="/js/local-search.js"></script>












  

  

</body>
</html>
